
heart_large_list = [13, 0x71c,0x8a2,0x1041,0x1001,0x1001,0x1001,0x802,0x404,0x208,0x110,0xa0,0x40]
heart_middle_list = [11, 0x18c,0x252,0x421,0x401,0x401,0x202,0x104,0x88,0x50,0x20]
heart_small_list = [9, 0x6c,0x92,0x101,0x101,0x82,0x44,0x28,0x10]

heart_large = [
	'0011100011100',
	'0100010100010',
	'1000001000001',
	'1000000000001',
	'1000000000001',
	'1000000000001',
	'0100000000010',
	'0010000000100',

	'0001000001000',
	'0000100010000',
	'0000010100000',
	'0000001000000'
]

def parse(glyph_list):
	width = glyph_list[0]
	height = len(glyph_list) - 1
	pages = height // 8 + 1 if height % 8 > 0 else height // 8
	byte_length = 8
	buffer = bytearray(pages * width)

	print(f'glyph info:\n\twidth: {width}\n\theight: {height}\n\tpages: {pages}')


	dot_matrix = []
	for line in glyph_list[1:]:
		line = bin(line).replace('0b', '').zfill(width)
		dot_matrix.append(line)
	
	# print(dot_matrix)

	new_dot_matrix = []
	for page in range(pages):
		for x in range(width):
			new_line = ''
			for y in range(byte_length - 1, -1, -1):
				try:
					new_line += dot_matrix[y + page * byte_length][x]
				except IndexError:
					new_line += '0'
			new_dot_matrix.append(new_line)

	# print(new_dot_matrix)
	for count, new_line in enumerate(new_dot_matrix):
		buffer[count] = int(new_line, 2)
	
	print(buffer)


if __name__ == '__main__':
	parse(heart_large_list)
